package controller

import (
	"devops/code"
	"devops/controller/validation"
	"devops/service"
	"github.com/gin-gonic/gin"
)

// @Summary 按时间获取事件
// @Tags DashbordEvent
// @Produce  json
// @Param	param  query  validation.GetAllEvent  true  "传入参数"
// @Success 200 {object} data.SuccessGetAllEvent  		"成功返回"
// @Failure 10000 {object} data.ParamError     			"错误返回"
// @Router /api/event/all [get]
func GetAllEvent(c *gin.Context) {
	var param validation.GetAllEvent
	if err := c.ShouldBind(&param); err != nil {
		ErrorResponse(c, code.PARAMETER_ERR, err.Error())
		return
	}
	validation.CheckPage(&param.Page)
	validation.CheckStartEndTime(&param.StartEnd)
	devops := service.NewDevOps()
	SuccessResponse(c, devops.GetAllEventTimeBetween(param.StartEnd.Start, param.StartEnd.End))
}